package com.ziytek.web.citizen.model.bean;

import com.ziytek.web.citizen.util.StringUtil;
import lombok.Builder;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author fenghx
 * @version 1.0
 * @className OneDetailsInfo
 * Description:
 * @date 2024/5/15 18:07
 */
@Data
@Builder
public class OneDetailsInfo {
    private Map<String, OneDetails> oneDetailsMap;
    private Map<String, String> controlVersionMap;
    private Map<String, Float> capacityMap;

    public void setOneDetails(String key, OneDetails oneDetails) {
        if (CollectionUtils.isEmpty(oneDetailsMap)) {
            oneDetailsMap = new HashMap<>();
        }
        if (oneDetails != null && StringUtil.isNotEmpty(key)) {
            oneDetailsMap.put(key, oneDetails);
        }
    }

    public void setControlVersion(String control, String version) {
        if (CollectionUtils.isEmpty(controlVersionMap)) {
            controlVersionMap = new HashMap<>();
        }
        if (StringUtil.isNotEmpty(version) && StringUtil.isNotEmpty(control)) {
            controlVersionMap.put(control, version);
        }
    }

    public void setCapacityMap(String key, Float capacity) {
        if (CollectionUtils.isEmpty(capacityMap)) {
            capacityMap = new HashMap<>();
        }
        if (StringUtil.isNotEmpty(key) && capacity != null) {
            capacityMap.put(key, capacity);
        }
    }
}
